Update example for converting DLC project to benchmark (v2)#49
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add frames_to_poseinterface utility to copy and rename frame images according to filenames in a COCO JSON file. Also fix the output filename of predictions_to_poseinterface to use _cliplabels.json suffix matching the naming convention. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a minimal DLC project under tests/data/dlc/ with 2 sessions, each containing a small (100 frames) video, placeholder PNGs, and annotation/prediction CSVs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace SWC-plusmaze_to_benchmark example with a new end-to-end example showing how to convert a DLC project to the poseinterface benchmark dataset format. Update sphinx-gallery config to execute examples, add API entries for new functions, and add jupyter and matplotlib dependencies. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
99eed8a to
6cfef6b
Compare
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
lochhh
left a comment
There was a problem hiding this comment.
Thanks @niksirbi !
I tried the example with a sample dlc project (that has annotations only) and it broke when it tries to find the predictions file. Otherwise the example works as expected. My suggestion is to skip the conversion(s) in the example if the expected files are not found.
It's very nice that we now have a sample DLC project in test data. I'm guessing the broken frame files are intentional, but it would be better to have actual frames, since this would allow us to have images with non-zero width and height in the COCO JSON files. As a follow-up PR, we should consider adding the generated benchmark dataset(s) as part of our test data. These could replace the current "reference dataset" Train/SWC-plusmaze/sub-M708149_ses-20200317/, giving us a more cohesive and internally consistent set of test fixtures (using the sample DLC project as test inputs and the reference dataset as expected outputs) - our current test data comes from a mix of sample inputs/outputs across different projects, along with multiple ad‑hoc fixtures.
Co-authored-by: Chang Huan Lo <changhuanlo@yahoo.com>
Co-authored-by: Chang Huan Lo <changhuanlo@yahoo.com>
Co-authored-by: Chang Huan Lo <changhuanlo@yahoo.com>
Add `import warnings` to io.py (needed after review suggestion introduced `warnings.warn`), update error message match in existing test, and add a new test for the partial-match warning path. Includes minor formatting fixes from ruff-format. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Chang Huan Lo <changhuanlo@yahoo.com>
The write_text() return value (byte count) was rendered as cell output by sphinx-gallery. Use capture_repr = () to suppress it. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Renders `Path | str` instead of `Union[Path, str]` in API docs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
Clean replacement for #40 (Frankenstein branch). Starts fresh from
main, builds on top of the now-merged #45 (predictions_to_poseinterface), and adds the gallery example plus supporting utilities and a lightweight test fixture.The example walks through the following workflow:
Warning
This example specifically documents the DLC-to-poseinterface conversion process. Trying it on other pose estimation software is encouraged, but adaptations will be needed, and the underlying functions are not yet tested on non-DLC inputs. Other source software will be tackled in future PRs.
What's included
frames_to_poseinterface: copies and renames frame images to match the filenames in aframelabels.json(unit tests included).tests/data/dlc/MouseTopDown-Loukia-2022-09-13/: 2 sessions, short MP4 videos, placeholder PNG frames, annotation + prediction CSVs. Used by tests and the gallery example.convert_dlc_to_benchmarksphinx-gallery example: replacing the oldSWC-plusmaze_to_benchmarkexample. Runs end-to-end against the bundled fixture and demonstrates the full DLC → benchmark conversion (video, framelabels + frame copy, videolabels) followed by clip extraction.treeutility: for displaying directory structures, used in the example (unit tests included).movementpin bumped to>=0.16.0(the version introducing the automatic source-software inference, whichpredictions_to_poseinterfacenow relies on).conf.pytree,frames_to_poseinterface, andpredictions_to_poseinterface.jupyter,matplotlib.Supersedes
How was this tested
I used a variant of this example locally to convert 2 sessions from a 'real' dataset (not just the fixture) and inspect the resulting .json files. The real dataset was structured similarly to the fixture included here.
Checklist
python examples/convert_dlc_to_benchmark.py)make clean htmlfromdocs/)How to review
I recommend primarily reviewing the built example end-to-end, and then diving into the newly introduced
tree/frames_to_poseinterfacefunctions if/when necessary.